﻿#pragma once
#include "as_socket.h"
#include "as_channel.h"
#include "as_callback.h"
#include "TcpConnection.h"
#include "byte_buffer.h"

namespace as
{
	namespace co
	{
		struct AcceptAwaiter
		{
			as::net::Socket& socket_;
			as::net::Channel* channel_ = nullptr;
			bool ready_ = false;
			bool await_ready();
			void await_suspend(as::co::coroutine_handle handle);
			void await_resume();
		};

		struct ReadAwaiter
		{
			~ReadAwaiter()
			{

			}

			std::shared_ptr<as::net::TcpConnection> conn_;
			std::weak_ptr<as::net::Channel> channel_;
			int ret_ = 0;

			bool await_ready();
			void await_suspend(as::co::coroutine_handle handle);
			int await_resume();
		};

		struct WriteAwaiter
		{
			~WriteAwaiter()
			{

			}
			ByteBufferPtr &buf_;
			as::net::Channel* channel_ = nullptr;
			bool ready_ = false;

			bool await_ready();
			void await_suspend(as::co::coroutine_handle handle);
			int await_resume();
		};
	}
}

